package com.trainfinder.requestor;

public class ExtractGO implements Extractor {

	/**
	 * @param args
	 */
	public String extract(String data) {
		final String STARTS_WITH = "We are currently processing your request, if your page has not updated within 10 seconds please <a href=\"" ;
		
	//	http://www.eurostar.com/dynamic/_SvBoWaitingTerm?_TMS=1145136288718&amp;_DLG=SvBoWaitingTerm&amp;_LANG=UK&amp;_AGENCY=ESTAR&amp;GO=1" id="continueUrl">continue here</a></p>";
		
		final String FROM = STARTS_WITH;
		final String ENDS_WITH = "\" id";

		String result ="";
		
		int start = data.indexOf(STARTS_WITH);

		if (start != -1) {
			int end = data.indexOf(ENDS_WITH, start + FROM.length());

			if (end != -1) {
				result = data.substring(start+ FROM.length(), end);
			}

		}
		
		result = result.replaceAll("&amp;","&");
		return result;
	}
}
